package No301_400.No391_400.NthDigit_400;

public class Solution {
    public static int findNthDigit(int n) {
    	int i = 9,j = 1;
    	int ith = i * j,count = 0;
        while (n > ith) {
			n = n - ith;
			j++;
			count += ith;
			ith = ith * 10 * j;
		}
        int nth = (n-1)%j;
        System.out.println(n);
        int result = (n-1)/(j)+count+1;
        String aString = String.valueOf(result);//.substring(nth, nth+1);
        return Integer.parseInt(aString);
	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		System.out.println(findNthDigit(1000000000));
	}

}
